const moment = require('moment');

const {sequelize} = require('../../core/db')
const {Sequelize, Model} = require('sequelize')

// 定义广告模型
class UserLogin extends Model {

}

// 初始广告模型
UserLogin.init({
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  is_student: {
    type: Sequelize.STRING(64),
    allowNull: false,
    comment: '是否为学生'
  },
  account: {
    type: Sequelize.STRING(64),
    allowNull: false,
    comment: '账号'
  },
  number: {
    type: Sequelize.STRING(64),
    allowNull: false,
    comment: '学号'
  },
  mail: {
    type: Sequelize.STRING(64),
    allowNull: false,
    comment: '邮箱'
  },
  nickname: {
    type: Sequelize.STRING(64),
    allowNull: false,
    comment: '昵称'
  },
  work_number: {
    type: Sequelize.STRING(64),
    allowNull: false,
    comment: '工号'
  },
  img: {
    type: Sequelize.STRING(64),
    allowNull: false,
    comment: '头像'
  },
  pwd: {
    type: Sequelize.STRING(64),
    allowNull: false,
    comment: '密码'
  },
  status: {
    type: Sequelize.INTEGER,
    allowNull: false,
    comment: '状态'
  },
  updated_at: {
    type: Sequelize.DATE,
    allowNull: false,
  },
  created_at: {
    type: Sequelize.DATE,
    allowNull: false,
    get() {
      return moment(this.getDataValue('created_at')).format('YYYY-MM-DD');
    }
  }
}, {
  sequelize,
  modelName: 'userLogin',
  tableName: 'user'
})

module.exports = {
    UserLogin
}
